import 'package:flutter/material.dart';
import 'package:riki_login/entity/staff_login_entity.dart';

import '../base_api.dart';

///作者：范玉辉
///创建时间：2021/8/17
///说明：
///说明：工人管家注册

///注册工人
class RegisterWorkerApi extends BaseApi<StaffLoginEntity> {
  RegisterWorkerApi(BuildContext context) : super(context);

  Map<String, String> params(String phone, String code, String clientType, String version, String deviceId) => {
        'phone': phone,
        'code': code,
        'employeeType': 'worker_staff',
        'clientType': clientType,
        'version': version,
        'deviceId': deviceId,
      };

  @override
  HttpMethod get httpMethod => HttpMethod.post;

  @override
  String apiMethod(params) => 'app/register/worker';

  @override
  StaffLoginEntity? onExtractResult(resultData, HttpData<StaffLoginEntity> data) {
    return resultData != null ? StaffLoginEntity.fromJson(resultData) : null;
  }
}

///注册管家
class RegisterButlerApi extends BaseApi<StaffLoginEntity> {
  RegisterButlerApi(BuildContext context) : super(context);

  Map<String, String> params(String phone, String code, String clientType, String version, String deviceId) => {
        'phone': phone,
        'code': code,
        'employeeType': 'butler',
        'clientType': clientType,
        'version': version,
        'deviceId': deviceId,
      };

  @override
  HttpMethod get httpMethod => HttpMethod.post;

  @override
  String apiMethod(params) => 'app/register/butler';

  @override
  StaffLoginEntity? onExtractResult(resultData, HttpData<StaffLoginEntity> data) {
    return resultData != null ? StaffLoginEntity.fromJson(resultData) : null;
  }
}
